package com.egao.common.module.recommendation.controller;

import com.egao.common.core.web.BaseController;
import com.egao.common.core.web.JsonResult;
import com.egao.common.core.web.PageParam;
import com.egao.common.core.web.PageResult;
import com.egao.common.module.recommendation.service.ICivilServiceApplicationRecommendationService;
import com.egao.common.module.recommendation.entity.CivilServiceApplicationRecommendation;
import com.egao.common.module.recommendation.entity.vo.RecommendationAuditParam;
import com.egao.common.module.recommendation.entity.vo.RecommendationListVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 公务员考试报名推荐表（应届生版） 控制器
 *
 * @author shu
 */
@Api(tags = "公务员考试报名推荐表（应届生版）管理")
@RestController
@RequestMapping("${api}")
public class CivilServiceApplicationRecommendationController extends BaseController {

    private final ICivilServiceApplicationRecommendationService civilServiceApplicationRecommendationService;


    @Autowired
    public CivilServiceApplicationRecommendationController(ICivilServiceApplicationRecommendationService civilServiceApplicationRecommendationService){
        this.civilServiceApplicationRecommendationService = civilServiceApplicationRecommendationService;
    }
    @PreAuthorize("hasAuthority('civilRec:list')")
    @ApiOperation("查询列表公务员考试报名推荐表（应届生版）")
    @GetMapping("/civilRec/list")
    public PageResult<RecommendationListVo> list(HttpServletRequest request) {
        PageParam<CivilServiceApplicationRecommendation> pageParam = new PageParam<>(request);
        return civilServiceApplicationRecommendationService.list(pageParam);
    }
    @PreAuthorize("hasAuthority('civilRec:read')")
    @ApiOperation("查询单个公务员考试报名推荐表（应届生版）")
    @GetMapping("/civilRec/read/{id}")
    public JsonResult read(@PathVariable("id") Integer id) {
        return civilServiceApplicationRecommendationService.read(id);
    }

    @PreAuthorize("hasAuthority('civilRec:my')")
    @ApiOperation("查询单个公务员考试报名推荐表（应届生版）")
    @GetMapping("/civilRec/my")
    public JsonResult read() {
        return civilServiceApplicationRecommendationService.read();
    }

    @PreAuthorize("hasAuthority('civilRec:add')")
    @ApiOperation("添加公务员考试报名推荐表（应届生版）")
    @PostMapping("/civilRec/add")
    public JsonResult add(@RequestBody CivilServiceApplicationRecommendation model) throws IOException {
        return civilServiceApplicationRecommendationService.add(model);
    }

    @PreAuthorize("hasAuthority('civilRec:deleted')")
    @ApiOperation("删除公务员考试报名推荐表（应届生版）")
    @DeleteMapping("/civilRec/delete/{ids}")
    public JsonResult delete(@PathVariable List<Integer> ids) {
        return civilServiceApplicationRecommendationService.delete(ids);
    }
    @PreAuthorize("hasAuthority('civilRec:submit')")
    @ApiOperation("提交公务员考试报名推荐表（应届生版）")
    @PostMapping("/civilRec/submit/{id}")
    public JsonResult submit(@PathVariable("id") Integer id) {
        return civilServiceApplicationRecommendationService.submit(id);
    }
    @PreAuthorize("hasAuthority('civilRec:audit')")
    @ApiOperation("辅导员审核公务员考试报名推荐表（应届生版）")
    @PostMapping("/civilRec/audit")
    public JsonResult audit(@RequestBody RecommendationAuditParam model) {//审核类
        return civilServiceApplicationRecommendationService.audit(model);
    }
    @PreAuthorize("hasAuthority('civilRec:export')")
    @ApiOperation("导出公务员考试报名推荐表（应届生版）")
    @GetMapping("/civilRec/export/{id}")
    public JsonResult export(@PathVariable("id") Integer id, HttpServletResponse response) throws IOException {
        return civilServiceApplicationRecommendationService.export(id,response);
    }

    @PreAuthorize("hasAuthority('civilRec:saveUpdate')")
    @ApiOperation("保存修改公务员考试报名推荐表（应届生版）")
    @PostMapping("/civilRec/saveUpdate")
    public JsonResult save(@RequestBody CivilServiceApplicationRecommendation model) throws IOException {
        return civilServiceApplicationRecommendationService.saveUpdate(model);
    }
}